<%@ page import="model.User" %><%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2025/11/7
  Time: 20:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加员工</title>
    <link rel="stylesheet" href="<%= request.getContextPath() %>/css/style.css">
</head>
<body>
<div class="navbar">
    <div class="logo">员工信息管理系统</div>
    <div class="user-info">
        <%
            User loginUser = (User) session.getAttribute("loginUser");
            String username = loginUser != null ? loginUser.getUsername() : "";
        %>
        欢迎您，<%= username %> |
        <a href="<%= request.getContextPath() %>/LogoutServlet">退出登录</a>
    </div>
</div>
<div class="container">
    <div class="sidebar">
        <ul>
            <li><a href="<%= request.getContextPath() %>/DashboardServlet">仪表盘</a></li>
            <li><a href="<%= request.getContextPath() %>/EmployeeServlet?action=list">员工管理</a></li>
        </ul>
    </div>
    <div class="content">
        <div class="content-header">
            <h3>添加员工</h3>
            <a href="<%= request.getContextPath() %>/EmployeeServlet?action=list" class="btn-back">返回列表</a>
        </div>
        <div class="form-container">
            <form action="<%= request.getContextPath() %>/EmployeeServlet" method="post">
                <input type="hidden" name="action" value="add">
                <div class="form-group">
                    <label for="name">姓名：</label>
                    <input type="text" id="name" name="name" required>
                </div>
                <div class="form-group">
                    <label for="department">部门：</label>
                    <select id="department" name="department" required>
                        <option value="技术部">技术部</option>
                        <option value="市场部">市场部</option>
                        <option value="人事部">人事部</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="position">职位：</label>
                    <input type="text" id="position" name="position" required>
                </div>
                <div class="form-group">
                    <label for="salary">薪资：</label>
                    <input type="number" id="salary" name="salary" step="0.01" required>
                </div>
                <div class="form-group">
                    <label for="email">邮箱：</label>
                    <input type="email" id="email" name="email">
                </div>
                <div class="form-group">
                    <label for="phone">电话：</label>
                    <input type="text" id="phone" name="phone">
                </div>
                <div class="form-group">
                    <label for="hireDate">入职日期：</label>
                    <input type="date" id="hireDate" name="hireDate" required>
                </div>
                <div class="error-msg"><%= request.getAttribute("errorMsg") != null ? request.getAttribute("errorMsg") : "" %></div>
                <div class="form-actions">
                    <button type="submit" class="btn-save">保存</button>
                    <button type="reset" class="btn-reset">重置</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
